<template>
	<!-- 自定义 tab-bar -->
	<view class="tab-bar">
		<view v-for="(item,index) in list" :key="index" class="tab-bar-item" @click="switchTab(item, index)">
			<image class="tab_img" :src="selected === index ? item.selectedIconPath : item.iconPath"></image>
			<view class="tab_text" :style="{color: selected === index ? selectedColor : color}">{{item.text}}</view>
		</view>
	</view>
</template>

<script>
	let app = ''
	export default {
		props: {
			selected: { // 当前选中的tab index
				type: Number,
				default: 0
			},
			// role: { //当前登录权限   0 普通客户  1 律师、管理员、小秘书
			// 	type: String,
			// 	default: '0',
			// }
		},
		data() {
			return {
				role:'0',
				"color": "#A3A8AB",
				"selectedColor": "#2DA9C5",
				"list1": [{
						"pagePath": "/pages/phone/customs/home/home",
						"iconPath": "/static/phone/phone_home.png",
						"selectedIconPath": "/static/phone/phone_home_press.png",
						"text": "首页"
					},
					{
						"pagePath": "/pages/phone/customs/caseDate/caseDate",
						"iconPath": "/static/phone/phone_case_date.png",
						"selectedIconPath": "/static/phone/phone_case_date_press.png",
						"text": "案件日程"
					},
					{
						"pagePath": "/pages/phone/customs/about/about",
						"iconPath": "/static/phone/phone_about.png",
						"selectedIconPath": "/static/phone/phone_about_press.png",
						"text": "关于我们"
					},
					{

						"pagePath": "/pages/phone/customs/mine/mine",
						"iconPath": "/static/phone/phone_mine.png",
						"selectedIconPath": "/static/phone/phone_mine_press.png",
						"text": "我的"
					}
				],
				"list2": [{
						"pagePath": "/pages/phone/customs/home/home",
						"iconPath": "/static/phone/phone_home.png",
						"selectedIconPath": "/static/phone/phone_home_press.png",
						"text": "首页"
					},
					{
						"pagePath": "/pages/phone/customs/caseDate/caseDate",
						"iconPath": "/static/phone/phone_case_date.png",
						"selectedIconPath": "/static/phone/phone_case_date_press.png",
						"text": "案件日程"
					},
					{
						"pagePath": "/pages/phone/manage/customManage/customManage",
						"iconPath": "/static/phone/phone_custom_manage.png",
						"selectedIconPath": "/static/phone/phone_custom_manage_press.png",
						"text": "客户管理"
					},
					{
						"pagePath": "/pages/phone/customs/mine/mine",
						"iconPath": "/static/phone/phone_mine.png",
						"selectedIconPath": "/static/phone/phone_mine_press.png",
						"text": "我的"
					}
				],
				list:[]
			}
		},
		onLoad() {
			
			
		},
		mounted() {
			// console.log("mounted")
			app = getApp()
			this.initRole()
		},
		methods: {
			initRole(){
				let _this = this
				
				_this.role = app.globalData.role
				if(_this.role=='0'){
					_this.list = _this.list1
				}else{
					_this.list = _this.list2
				}
			},
			switchTab(item, index) {
				console.log('switchTab')
				let url = item.pagePath;
				// console.log(url)
				uni.switchTab({
					url
				})
		
			}
		
		}
	}
</script>

<style lang="scss">
	.tab-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		height: 128rpx;
		background: white;
		display: flex;
		justify-content: center;
		align-items: center;
		background: #FFFFFF;
		box-shadow: 14rpx 0 12rpx 0 rgba(0, 0, 0, 0.09);
		padding-bottom: env(safe-area-inset-bottom); // 适配iphoneX的底部
	
		.tab-bar-item {
			flex: 1;
			text-align: center;
			display: flex;
			justify-content: center;
			align-items: center;
			flex-direction: column;
	
			.tab_img {
				width: 52rpx;
				height: 52rpx;
			}
	
			.tab_text {
				font-size: 24rpx;
				margin-top: 4rpx;
			}
		}
	}
</style>
